
/******************************************************************************
*@file  : app.c
*@brief : application
******************************************************************************/

#include "hal.h"   

void APP_Test(void)
{
    uint8_t  result; 
    uint32_t testAddr = 0x08000FFC;
  	
    printfS("1.addr-0x%08x:0x%08x\n",testAddr, *(uint32_t *)testAddr);     
     
    result = HAL_NORFLASH_Protect(NORFLASH_BP_BOTTOM_4KB);     
    
    printfS("protect Result:%d.\n", result);   
    
    if (0 == result)  
    {
        HAL_NORFLASH_BackupEraseProgram(0x08000FFC,(uint8_t *)"1234",4);
        // Data should not be erased at 0x08000000  
        printfS("2.addr-0x%08x:0x%08x\n",testAddr, *(uint32_t *)testAddr);         
    }
      
    result = HAL_NORFLASH_Protect(NORFLASH_BP_NONE);  
    printfS("unprotect Result:%d.\n", result);   
    
    if (0 == result)  
    {
        HAL_NORFLASH_BackupEraseProgram(0x08000FFC,(uint8_t *)"5678",4);
        printfS("3.addr-0x%08x:0x%08x\n",testAddr, *(uint32_t *)testAddr); 
        
        HAL_NORFLASH_BackupEraseProgram(0x08000FFC,(uint8_t *)"0000",4);
        printfS("4.addr-0x%08x:0x%08x\n",testAddr, *(uint32_t *)testAddr);         
    }    
    
  
          
}






